Abstract
High-Frequency trading models are an interesting proposal in quantic finance, since its a different approach from what traditional trading and finance means; in this project we are going to dive deep into two of the most know High-Frequency trading models, from the Asset Pricing Theory: Martingale; which states that, from a market microstructure perspective, a price in the future will be exactly the same as the present price; i.e: $p_{t+1} = p_t.$
Keeping the same market microstructure perspective, we have the Roll model (1984) which... </font>
In this project we are going to dive deep into two of the most known High-Frequency Trading Models; the Asset Pricing Theory which statets that the price of a risky asset, $P_t$, from a consuming model in present and future time, under the perspective of the market microstructure, can be modeled as a stochastic process named martingale.
A martingale is a sequence of random variables (i.e., a stochastic process) for which, at a particular time (in seconds or milliseconds), in this case, from the perspective of the market microstructure, the conditional expectation of the next value in the sequence is equal to the present value, regardless of all prior values i.e.: $p_{t+1} = p_t$.
This is going to be probed using an orderbook containing about 2400 timestamps. We are going to divide and group by minutes and count occurrences for martingales and non martingales.
The second model is the Roll Model (1984)...
In order to run this notebook, it is necessary to have installed and/or have the requirements.txt file with the following:
import plotly.io as pio
pio.renderers.default='notebook'
import main as mn
import functions as fn
import visualizations as vz
e1 = mn.e1
e1[:3]
| intervalo | total | e1 | e1_proportion | e2 | e2_proportion | |
|---|---|---|---|---|---|---|
| 0 | 0 | 41 | 27 | 0.6585 | 14 | 0.3415 |
| 1 | 1 | 40 | 32 | 0.8000 | 8 | 0.2000 |
| 2 | 2 | 39 | 27 | 0.6923 | 12 | 0.3077 |
e1.tail(3)
| intervalo | total | e1 | e1_proportion | e2 | e2_proportion | |
|---|---|---|---|---|---|---|
| 57 | 57 | 41 | 29 | 0.7073 | 12 | 0.2927 |
| 58 | 58 | 40 | 27 | 0.6750 | 13 | 0.3250 |
| 59 | 59 | 39 | 31 | 0.7949 | 8 | 0.2051 |
In order to probe if the midprices or weighted midprices follow an stochastic process, a martingale, it is necessaary to probe the following statement: $p_{t+1} = p_t$.
Where
$p_{t+1} = \text{future price}$
and
$p_{t} = \text{present price}$
It is easy to probe by using a list comprehension
True_False_list = [midprice[i+1] == midprice[i] for i in range(len(midprice)-1)]
print('The average proportion of martingale is', mn.e11_mean, 'and for no-martingales:', mn.e12_mean)
The average proportion of martingale is 0.73 and for no-martingales: 0.27
e2 = mn.e2
e2[:3]
| intervalo | total | e1 | e1_proportion | e2 | e2_proportion | |
|---|---|---|---|---|---|---|
| 0 | 0 | 41 | 27 | 0.6585 | 14 | 0.3415 |
| 1 | 1 | 40 | 27 | 0.6750 | 13 | 0.3250 |
| 2 | 2 | 39 | 26 | 0.6667 | 13 | 0.3333 |
e2.tail(3)
| intervalo | total | e1 | e1_proportion | e2 | e2_proportion | |
|---|---|---|---|---|---|---|
| 57 | 57 | 41 | 27 | 0.6585 | 14 | 0.3415 |
| 58 | 58 | 40 | 27 | 0.6750 | 13 | 0.3250 |
| 59 | 59 | 39 | 26 | 0.6667 | 13 | 0.3333 |
print('The average proportion of martingale is', mn.e21_mean, 'and for no-martingales:', mn.e22_mean)
The average proportion of martingale is 0.68 and for no-martingales: 0.32
The proportions change within the midprice and weighted midprice, but the martingale proportions is sill the highest one
# DELETE THIS CELL IN YOUR FILE
# Another particular process that is relevant for the work. Normally, you include between 2 and 5 at the most.
e1_plot = vz.exp1_plot(df = e1, x = 'intervalo', y = ['e1', 'e2'])
The result is consistent in the whole minute, but less consistent than the weighted midprice result
e2_plot = vz.exp1_plot(df = e2, x = 'intervalo', y = ['e1', 'e2'])
The result is consistent in the whole minute.
By observing the two results, we can conclude than in a microstructure market perspective, about 70% of the data will follow an stochastic process: a martingale.
# DELETE THIS CELL IN YOUR FILE
# You can have several processes with which you are obtaining the results you need.
[1] Munnoz, 2020. Python project template. https://github.com/iffranciscome/python-project. (2021).
[2] Martingale. Encyclopedia of Mathematics. URL: http://encyclopediaofmath.org/index.php?title=Martingale&oldid=49256